package com.wz.dhs.model;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

/**
 * @description: 后台管理统一分页请求VO
 * @author: xia
 * @createDate: 2020/7/4
 */
@Data
public class PageRequestResultVO<T> {

    private T data;

    private Long totalNum;

    /**
     * @description: 分页结果返回
     * @author: xia
     * @createTime: 2020/7/4  10:42
     * @version: v1.0.0
     * @param:
     * @return:
     * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public static <T> PageRequestResultVO<T> createPageResult(Long totalNum, T data) {
        PageRequestResultVO result = new PageRequestResultVO<>();
        result.setData(data);
        result.setTotalNum(totalNum);
        return result;
    }

    /**
     * @description: 分页结果返回
     * @author: xia
     * @createTime: 2020/7/4  10:54
     * @version: v1.0.0
     * @param:
     * @return:
     * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public static <T> PageRequestResultVO<T> createPageResult(IPage page) {
        PageRequestResultVO result = new PageRequestResultVO<>();
        result.setData(page.getRecords());
        result.setTotalNum(page.getTotal());
        return result;
    }

}
